package com.xbongbong.workflow.config;

import com.xbongbong.workflow.service.strategy.data.WorkflowDataProcessStrategy;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * 节点策略的config
 * @author 魏荣杰
 * @date 2021/5/10 15:23
 * @since
 * @version
 */
@Configuration
public class WorkflowDataProcessStrategyConfig {

    @Autowired
    private Map<String, WorkflowDataProcessStrategy> workflowDataProcessStrategyMap;

    @Bean("workflowDataProcessStrategyMap")
    public Map<Integer, WorkflowDataProcessStrategy> initWorkflowDataProcessStrategyMap() {
        Map<Integer, WorkflowDataProcessStrategy> result = new HashMap<>();
        workflowDataProcessStrategyMap.forEach((key, item) -> {
            item.type().forEach(k -> {
                result.put(k, item);
            });
        });
        return result;
    }
}
